<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:atom="http://www.w3.org/2005/Atom"
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
                xmlns:planet="http://planet.intertwingly.net/"
		exclude-result-prefixes="atom planet xhtml">
 
<xsl:output method="html" 
			doctype-public="-//W3C//DTD HTML 4.01//EN" 
			doctype-system="http://www.w3.org/TR/html4/strict.dtd"
			indent="yes"
			encoding="utf-8"/>

  <xsl:template match="atom:feed">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="robots" content="noindex,nofollow" />
	<meta name="generator" content="{atom:generator}" />
	<title><xsl:value-of select="atom:title"/></title>

    <xsl:if test="atom:link[@rel='self']">
    <link rel="alternate" 
			href="{atom:link[@rel='self']/@href}"
       		title="{atom:title}" 
			type="{atom:link[@rel='self']/@type}" />
	</xsl:if>
	<style type="text/css" media="screen">
*{padding:0;margin:0;}
h1, h2, h3, h4, h5, h6, p, pre, blockquote, label, ul, ol, dl, fieldset, address { margin:1em 0; }
li, dd { margin-left:5%; }
body{font:normal medium Consolas, Lucida Console, Monaco, monospace;margin:1.75em auto;width:40em;line-height:1.1}
h1{display:none}
h1, h2, h3, h4 { font-family: Futura Medium, Century Gothic, AppleGothic, sans-serif;}
h2{text-align:right;border-bottom:1px solid #aaa;color:#333;}
ul{list-style:none;margin-left:0;padding-left:0}
a,a:visited,a:hover,a:active,a:link{color:green}
h3 a{color:#000 ! important}
img{border:1px grey;padding:2px}
li{clear:both}
blockquote{font-size:small;margin:2.0em 0;padding:0;font-style:oblique;border-left:1px dotted;padding-left:1.1em}
span.logo{font-size:large;color:magenta;}
.h li{display:inline}
.source{font-size:small;float:right;}
.content{margin:1.5em 1.1em;font-size:small;}
#footer{clear:both;text-align:center;font-size:x-small}
.details{display:block;text-align:right;font-family:Futura Mediumm, Century Gothic,AppleGothic,sans-serif;font-size:small}
	</style>
	<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
    <link rel="icon" type="image/x-icon"  href="images/planet.ico" />
</head>

<body>
	<h1><xsl:value-of select="atom:title"/></h1>
	<xsl:apply-templates select="atom:entry"/>
	<hr/>
	<xsl:apply-templates select="." mode="footer" />
</body>
</html>
  </xsl:template>


	<xsl:template match="atom:feed" mode="footer">
		<div id="footer">
			<p>Sources:</p>
			<ul class="h">
				<xsl:apply-templates select="planet:source">
					<xsl:sort select="planet:name"/>
				</xsl:apply-templates>
			</ul>
			<hr/>
          	<p>
              <span title="Last updated GMT">
                <xsl:value-of select="atom:updated/@planet:format"/>
              </span>&#160;&#160;<span class="logo">♀</span>&#160;&#160;<a href="http://intertwingly.net/code/venus/" title="Powered by Sam Ruby’s Venus">Venus</a>
			</p>
		</div>
	</xsl:template>
	

	<xsl:template match="planet:source">
       <li><a href="{atom:link[@rel='alternate']/@href}">
          <xsl:choose>
            <xsl:when test="planet:message">
              <xsl:attribute name="class">message</xsl:attribute>
              <xsl:attribute name="title">
                <xsl:value-of select="planet:message"/>
              </xsl:attribute>
            </xsl:when>
            <xsl:when test="atom:title">
              <xsl:attribute name="title">
                <xsl:value-of select="atom:title"/>
              </xsl:attribute>
            </xsl:when>
          </xsl:choose>
          <xsl:value-of select="planet:name"/>
        </a></li>
	</xsl:template>
	

 
  <xsl:template match="atom:entry">

    <xsl:variable name="date" select="substring(atom:updated,1,10)"/>
    <xsl:if test="not(preceding-sibling::atom:entry
      [substring(atom:updated,1,10) = $date]) and preceding-sibling::atom:entry">
	<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
	</xsl:if>
    <xsl:if test="not(preceding-sibling::atom:entry[substring(atom:updated,1,10) = $date])">
      <h2 class="date">
        <xsl:value-of select="substring-before(atom:updated/@planet:format,', ')"/>
        <xsl:text>, </xsl:text>
        <xsl:value-of select="substring-before(substring-after(atom:updated/@planet:format,', '), ' ')"/>
      </h2>
	<xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
    </xsl:if>

		
    <li>
		<xsl:choose>
			    <xsl:when test="atom:source/atom:icon">
		              <img src="{atom:source/atom:icon}" class="icon" alt="{atom:source/planet:name}" />
			    </xsl:when>
			    <xsl:otherwise>
		              <span class="source"><xsl:value-of select="atom:source/planet:name"/></span>
			    </xsl:otherwise>
       </xsl:choose>
		
        <xsl:if test="atom:title">
          <h3><a href="{atom:link[@rel='alternate']/@href}">
            <xsl:if test="atom:title/@xml:lang != @xml:lang">
              <xsl:attribute name="xml:lang" select="{atom:title/@xml:lang}"/>
            </xsl:if>
            <xsl:value-of select="atom:title"/>
          </a></h3>
        </xsl:if>

      <div class="content">
      <xsl:choose>
        <xsl:when test="atom:content">
          <xsl:apply-templates select="atom:content"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="atom:summary"/>
        </xsl:otherwise>
      </xsl:choose>
  	  </div>
	
	<span class="details">
      <xsl:if test="atom:link[@rel='license'] or
                     atom:source/atom:link[@rel='license'] or
                     atom:rights or atom:source/atom:rights">
        <a class="licence">
           <xsl:if test="atom:source/atom:link[@rel='license']/@href">
             <xsl:attribute name="rel">license</xsl:attribute>
             <xsl:attribute name="href">
               <xsl:value-of select="atom:source/atom:link[@rel='license']/@href"/>
             </xsl:attribute>
           </xsl:if>
           <xsl:if test="atom:link[@rel='license']/@href">
             <xsl:attribute name="rel">license</xsl:attribute>
             <xsl:attribute name="href">
               <xsl:value-of select="atom:link[@rel='license']/@href"/>
             </xsl:attribute>
          </xsl:if>
           <xsl:if test="atom:source/atom:rights">
             <xsl:attribute name="title">
               <xsl:value-of select="atom:source/atom:rights"/>
             </xsl:attribute>
           </xsl:if>
           <xsl:if test="atom:rights">
             <xsl:attribute name="title">
               <xsl:value-of select="atom:rights"/>
             </xsl:attribute>
           </xsl:if>
           <xsl:text>&#x00A9;&#160;</xsl:text>
         </a>
       </xsl:if>
       <a href="{atom:link[@rel='alternate']/@href}" class="permalink">
         <span class="date" title="GMT">
           <xsl:value-of select="substring-before(substring-after(atom:updated,'T'),'Z')"/>
         </span>
       </a>
</span>
    </li>

    <xsl:if test="not(following-sibling::atom:entry)">
	<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
	</xsl:if>
  </xsl:template>

  <!-- xhtml content -->
  <xsl:template match="atom:content/xhtml:div | atom:summary/xhtml:div">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
  </xsl:template>

  <!-- plain text content -->
  <xsl:template match="atom:content/text() | atom:summary/text()">
    <div>
      <xsl:copy-of select="."/>
    </div>
  </xsl:template>

  <!-- Feedburner detritus -->
  <xsl:template match="xhtml:div[@class='feedflare']"/>

  <!-- Remove stray atom elements -->
  <xsl:template match="atom:*">
    <xsl:apply-templates/>
  </xsl:template>

  <!-- pass through everything else -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
